<?php

include "../../lib/start.php";

check_session();
check_permission(ADM_PERM);

if(!isset($_GET['offset']))
    $offset = 0;
else
    $offset = $_GET['offset'];

$limit = 9;

$anno = $_SESSION['__current_year__']->get_ID();

$sel_cls = "SELECT id_classe, anno_corso, tempo_prolungato, sezione, sedi.nome FROM classi, sedi WHERE sede = sedi.id_sede ORDER BY sezione, anno_corso ";

if(!isset($_GET['second'])){
    $res_cls = $db->execute($sel_cls);
    //print $sel_links;
    $count = $res_cls->num_rows;
    $_SESSION['count_cls'] = $count;
}
else{
    $sel_cls .= "LIMIT $limit OFFSET $offset";
    $res_cls = $db->execute($sel_cls);
}

if($offset == 0)
    $page = 1;
else
    $page = ($offset / $limit) + 1;

$pagine = ceil($_SESSION['count_cls'] / $limit);
if($pagine < 1)
    $pagine = 1;
    
// dati per la paginazione (navigate.php)
$colspan = 4;
$link = basename($_SERVER['PHP_SELF']);
$count_name = "count_cls";
$row_class = "admin_row";

include "classi.html.php";


?>